# encoding: utf-8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/3/21 10:08
# @Author  : 柳晓飞
# @Site    : 
# @File    : deal.py
# @Software: PyCharm
import card
from random import shuffle

def deal(playerNum):
    allCards = []
    for a in card.CardType:
        for i in range(0,4):
            start = 16*a.value + 1
            end = start + 9
            for j in range(start, end):
                allCards.append(j)

    shuffle(allCards)
    playerCardsDict= {}
    for i in range(0,playerNum):
        cards = []
        for j in range(0,8):
            cards.append(allCards.pop())
        playerCardsDict[i]= cards

    leftCards= allCards
    return playerCardsDict,leftCards
    #return getAsignCards()
def getAsignCards():
    allCards = []
    for a in card.CardType:
        for i in range(0, 4):
            start = 16 * a.value + 1
            end = start + 9
            for j in range(start, end):
                allCards.append(j)

    shuffle(allCards)
    playerCardsDict = {}

    cards0 = [1,1,1,2,3,3,5,7]
    playerCardsDict[0] = cards0

    cards1 = [1,1,1,2,3,4,6,7]
    playerCardsDict[1] = cards1

    cards2 = [1,1,1,2,3,3,6,7]
    playerCardsDict[2] = cards2

    leftCards = [5,5,5,5,5,5,5,5,5,5,5]
    return playerCardsDict, leftCards
